cmake_minimum_required(VERSION 2.8)
project(aaa)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -rdynamic -O3 -fPIC -ggdb -std=c++11 -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations")
set(CMAKE_C_FLAGS "$ENV{CXXFLAGS} -rdynamic -O3 -fPIC -ggdb -std=c11 -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations")

include_directories(.)
include_directories(../yaml-cpp/include)

find_library(YAMLCPP libyaml-cpp.a /home/aaa/workspace/yaml-cpp)
find_library(PTHREAD pthread)
find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND)
    include_directories(${OPENSSL_INCLUDE_DIR})
endif()

set(LIB_SRC
    aaa/address.cc
    aaa/config.cc
    aaa/env.cc
    aaa/fd_manager.cc
    aaa/fiber.cc
    aaa/hook.cc
    aaa/http.cc
    aaa/iomanager.cc
    aaa/log.cc
    aaa/mutex.cc
    aaa/scheduler.cc
    aaa/socket.cc
    aaa/tcp_server.cc
    aaa/thread.cc
    aaa/timer.cc
    aaa/util.cc
    )

add_library(aaa SHARED ${LIB_SRC})


set(LIB
    aaa
    pthread
    yaml-cpp
    dl
    ${OPENSSL_LIBRARIES}
    )


add_executable(test tests/test.cc)
add_dependencies(test aaa)
target_link_libraries(test ${LIB})


SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)